using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

using DataAccess;
using DataTransferObject;

namespace Business
{
    public enum TacGiaBUSResult
    {
        OK,
        MATGERROR,
        TENTGERROR,
        DAOERROR
    }

    public class clsTacGiaBUS
    {
        //Fields.
        private clsTacGiaDAO TacGiaDAO;

        //Constructors.
        public clsTacGiaBUS()
        {
            this.TacGiaDAO = new clsTacGiaDAO();
        }

        #region Methods

        public TacGiaBUSResult KiemTraRong(clsTacGiaDTO obj)
        {
            if (obj.MaTG == "")
                return TacGiaBUSResult.MATGERROR;
            if ((obj.TenTG == ""))
                return TacGiaBUSResult.TENTGERROR;
            return TacGiaBUSResult.OK;
        }

        public DataTable DanhSachTacGia()
        {
            return this.TacGiaDAO.SelectAll();
        }

        public TacGiaBUSResult ThemTacGia(clsTacGiaDTO obj)
        {
            if (!this.TacGiaDAO.Insert(obj))
                return TacGiaBUSResult.DAOERROR;
            return TacGiaBUSResult.OK;
        }

        public TacGiaBUSResult SuaTacGia(clsTacGiaDTO obj)
        {
            if (!this.TacGiaDAO.Update(obj))
                return TacGiaBUSResult.DAOERROR;
            return TacGiaBUSResult.OK;
        }

        public TacGiaBUSResult XoaTacGia(clsTacGiaDTO obj)
        {
            if (!this.TacGiaDAO.Delete(obj))
                return TacGiaBUSResult.DAOERROR;
            return TacGiaBUSResult.OK;
        }
        #endregion
    }
}

